package org.teremail.delivery;

import java.util.Collection;

import org.teremail.message.Address;
import org.teremail.message.Message;

public class Envelope {

    private final Address sender;
    private final Collection<Address> recpts;
    private final Message message;

    public Envelope(Address sender, Collection<Address> recpts, Message saved) {
        this.sender = sender;
        this.recpts = recpts;
        this.message = saved;
    }

    public Message getMessage() {
        return message;
    }
    
    public Address getSender() {
        return sender;
    }
    
    public Collection<Address> getRecipients() {
        return recpts;
    }

    /**
     * Returns a new Envelope on change of messsage.
     * 
     * @param e
     * @param m
     * @return
     */
    public Envelope setMessage(Message m) {
        return new Envelope(getSender(), getRecipients(), m);
    }
}
